package com.juntuo.util;


import com.alibaba.fastjson.JSON;
import com.juntuo.Enums.Constants;
import org.apache.http.HttpResponse;
import org.apache.poi.ss.formula.ptg.MemAreaPtg;

import java.util.HashMap;
import java.util.Map;

public class BaiduMapUtil {

    public static Map<String,String> getArea(Double lat,Double lon) throws Exception {
        String url = Constants.BAIDU_LOCATION_URL.replace("locationParam",lat+","+lon);
        String content=HttpClientUtil.httpGet(url);
        Map<String,Object> map =(Map<String,Object>)JSON.parse(content);
        Map<String,Object> result=(Map<String,Object>)map.get("result");
        Map<String,Object> addressComponent=(Map<String,Object>)result.get("addressComponent");
        Map<String,String> area = new HashMap<>(3);
        area.put("province",(String)addressComponent.get("province"));
        area.put("city",(String)addressComponent.get("city"));
        area.put("district",(String)addressComponent.get("district"));
        return area;
    }




}
